package com.party.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.DataSource;
import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.core.page.TableDataInfo;
import com.party.common.enums.BusinessType;
import com.party.common.enums.DataSourceType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.business.domain.WebinfoPictures;
import com.party.business.service.IWebinfoPicturesService;

/**
 * 图片库Controller
 *
 * @author ruoyi
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/business/pictures")
public class WebinfoPicturesController extends BaseController {
    @Autowired
    private IWebinfoPicturesService webinfoPicturesService;

    /**
     * 查询图片库列表
     */
//@RequiresPermissions("business:pictures:list")
    @GetMapping("/list")
    @DataSource(value = DataSourceType.SLAVE)
    public TableDataInfo list(WebinfoPictures webinfoPictures) {
        startPage();
        List<WebinfoPictures> list = webinfoPicturesService.selectWebinfoPicturesList(webinfoPictures);
        return getDataTable(list);
    }

    /**
     * 导出图片库列表
     */
    //@RequiresPermissions("business:pictures:export")
    @Log(title = "图片库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebinfoPictures webinfoPictures) {
        List<WebinfoPictures> list = webinfoPicturesService.selectWebinfoPicturesList(webinfoPictures);
        ExcelUtil<WebinfoPictures> util = new ExcelUtil<WebinfoPictures>(WebinfoPictures.class);
        util.exportExcel(response, list, "图片库数据");
    }

    /**
     * 获取图片库详细信息
     */
    //@RequiresPermissions("business:pictures:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(webinfoPicturesService.getById(id));
    }

    /**
     * 新增图片库
     */
    //@RequiresPermissions("business:pictures:add")
    @Log(title = "图片库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebinfoPictures webinfoPictures) {
        return toAjax(webinfoPicturesService.save(webinfoPictures));
    }

    /**
     * 修改图片库
     */
    //@RequiresPermissions("business:pictures:edit")
    @Log(title = "图片库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebinfoPictures webinfoPictures) {
        return toAjax(webinfoPicturesService.updateById(webinfoPictures));
    }

    /**
     * 删除图片库
     */
    //@RequiresPermissions("business:pictures:remove")
    @Log(title = "图片库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(webinfoPicturesService.removeByIds(Arrays.asList(ids)));
    }
}
